﻿using System.Drawing;

namespace XYAC.Framework.MonitorTireMaterialOnline.DataExporter
{

    public class Line
    {
        private PointF m_P1;
        private PointF m_P2;

        public Line(PointF p1, PointF p2)
        {
            this.m_P1 = p1;
            this.m_P2 = p2;
        }
        /// <summary>
        /// 线段的斜率
        /// </summary>
        /// <returns></returns>
        private float GVal()
        {
            if (this.XDiff == 0f)
            {
                return 0f;
            }
            return (this.YDiff / this.XDiff);
        }

        public void SetOffsetXVal(float Val)
        {
            this.m_P1.X += Val;
            this.m_P2.X += Val;
        }

        public void SetOffSetYVal(float Val)
        {
            this.m_P1.Y += Val;
            this.m_P2.Y += Val;
        }

        public float K
        {
            get
            {
                return this.GVal();
            }
        }

        public PointF P1
        {
            get
            {
                return this.m_P1;
            }
        }

        public PointF P2
        {
            get
            {
                return this.m_P2;
            }
        }

        public float XDiff
        {
            get
            {
                return (this.m_P2.X - this.m_P1.X);
            }
        }

        public float YDiff
        {
            get
            {
                return (this.m_P2.Y - this.m_P1.Y);
            }
        }
    }
}
